<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="language" content="en" />

    <?php
    if (!Yii::app()->clientScript->isScriptFileRegistered("jquery") ){
        Yii::app()->clientScript->registerCoreScript('jquery');
    }
    ?>

	<!-- blueprint CSS framework -->
	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/screen.css" media="screen, projection" />
	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/print.css" media="print" />
	<!--[if lt IE 8]>
	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/ie.css" media="screen, projection" />
	<![endif]-->

    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/general.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/base.css" />
	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main.css" />
	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/form.css" />

    <link href='http://fonts.googleapis.com/css?family=Tangerine' rel='stylesheet' type='text/css'>
    <link href='http://fonts.googleapis.com/css?family=Josefin+Sans' rel='stylesheet' type='text/css'>
	<title><?php echo CHtml::encode($this->pageTitle); ?></title>

    <?php
    Yii::app()->clientScript->registerScript("switchLanguage", "
        function switchLanguage (lang){
            switch (lang){
                case 'es':
                        $('#hidden-lang').val(lang);
                        $('#language-form').submit();
                    break;
                case 'en':
                        $('#hidden-lang').val(lang);
                        $('#language-form').submit();
                    break;
            }

        }
    ", CClientScript::POS_END);
    ?>
</head>

<body>

<div id="full-header">
    <div id="header">
        <div id="logo"><?php echo CHtml::encode(Yii::app()->name); ?></div>
        <div id="language-bar">

            <?php if (Yii::app()->user->checkAccess("admin")){ ?>
            <div style="float: left; padding-left: 10px;">
                <a href="/producto">Productos</a> &nbsp;|&nbsp;
                <a href="/categoria">Categorías</a>
            </div>
            <?php } ?>

            <?php
            echo CHtml::form('', 'post', array('id' => 'language-form'));
            echo CHtml::image('/images/flag-argentina-32.png', 'Español', array('onclick' => 'switchLanguage("es")','class' => 'arg', 'title'=>'Español'));
            echo CHtml::image('/images/flag-usa-32.png', 'English', array('onclick' => 'switchLanguage("en")','class' => 'usa', 'title'=>'English'));
            echo CHtml::hiddenField('_lang', Yii::app()->language, array('id' => 'hidden-lang'));
            echo CHtml::endForm();
            ?>
        </div>
    </div><!-- header -->


    <div id="mainmenu" class="<?php echo ($this->id == "site" && $this->action->id == "index") ? "hidden" : ""?>">
        <?php $this->widget('zii.widgets.CMenu',array(
            'items'=>array(
                array('label'=> Yii::t('app', 'mainMenu.home'), 'url'=>array('/inicio')),
                array('label'=> Yii::t('app', 'mainMenu.catalog'), 'url'=>array('/catalogo'), 'active' => ($this->id == 'site' && $this->action->id == 'catalogo') ? true:false),
                array('label'=> Yii::t('app', 'mainMenu.aboutUs'), 'url'=>array('/'.Yii::t("app","mainMenu.aboutUs.slug"))),
                array('label'=> Yii::t('app', 'mainMenu.contact'), 'url'=>array('/'.Yii::t("app","mainMenu.contact.slug"))),
                array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
                array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)
            ),
        )); ?>
    </div><!-- mainmenu -->

</div>

<div class="container" id="page">

    <?php if(isset($this->breadcrumbs)):?>
        <?php $this->widget('zii.widgets.CBreadcrumbs', array(
			'homeLink' => CHtml::link(Yii::t('app', 'mainMenu.home'), Yii::app()->homeUrl),
			'links'=>$this->breadcrumbs,
		)); ?><!-- breadcrumbs -->
    <?php endif ?>

	<?php echo $content; ?>

	<div class="clear"></div>

	<div id="footer">
		Copyright &copy; <?php echo date('Y'); ?> by <?php echo Yii::app()->name ?>.<br/>
		All Rights Reserved.<br/>
	</div><!-- footer -->

</div><!-- page -->

</body>
</html>
